package com.ott.Util;

import java.util.Arrays;
import java.util.Map;

public class SortEncryptUtil {

	public static String getMD5SortSign(Map<String, String> paramMap){
		
		StringBuilder stringBuilder = new StringBuilder();
		// 对参数名进行字典排序
		String[] keyArray = paramMap.keySet().toArray(new String[0]);
		Arrays.sort(keyArray);
		// 拼接有序的参数名-值串
		for (String key : keyArray) {
			stringBuilder.append(key + "=" + paramMap.get(key) + "&");
		}
		String codes = stringBuilder.toString();

		String sign = MD5Util.MD5(codes.substring(0, codes.length() - 1)).toLowerCase();
		
		return sign;
	}
}
